<?php
require_once "core/application/models/mpremiums/mpremiums.php";
$m_premiums = new Premiums_Model();
echo "<p><a href='index?adm&control&what=addPremium'>Добавить премиум</a>";
$res = $m_premiums->listPremiumAccounts();
$fetch = mysql_fetch_assoc(&$res);
$num_rows = mysql_num_rows(&$res);
if ($num_rows) {
    ?>
    <table style="border-collapse: collapse; width: 100%" border="2">
        <tr><td></td><td><b>ID аккаунта</b></td><td><b>Аккаунт</b></td><td><b>Статус</b><td><b>Дата окончания</b></td><td><b>IP адрес</b></td></tr>
        <?php
        //while in array $fetch we have records - do
        do {
            switch ($fetch['membership']) {
                case 2: $membership = "VIP";
                    break;
                case 1: $membership = "Premium";
                    break;
            }
            if ($fetch['expire'] == '') {
                $time_end = "никогда";
            } else {
                $time_end = $fetch['expire'];
            }
            printf("<tr><td><a href='index?adm&control&what=deletePremium&account=%s'><img src='content/images/del_ban.gif'></img></a></td><td>%s </td><td>%s </td><td>%s</td><td>%s </td><td>%s</td></tr>"
                    , $fetch['name'], $fetch['id'], $fetch['name'], $membership, $time_end, $fetch['last_ip']);
        } while ($fetch = mysql_fetch_assoc(&$res));
        ?>
    </table>
    <?php
} else {
    echo "<p>Премиум аккаунтов нет. Хотите <a href='index?adm&control&what=addPremium'>добавить ?</a>";
}
?>